MESSAGE(STATUS "initiliaze XCMAKE environment")
MESSAGE(STATUS "target os: " ${CMAKE_SYSTEM_NAME} " version " ${CMAKE_SYSTEM_VERSION})
MESSAGE(STATUS "c compiler: " ${CMAKE_C_COMPILER_ID})
MESSAGE(STATUS "cc compiler: " ${CMAKE_CXX_COMPILER_ID})

#设置XCMAKE 操作系统环境变量
SET(XCMAKE_OS ${CMAKE_SYSTEM_NAME})
SET(XCMAKE_OS_WIN FALSE)
SET(XCMAKE_OS_LINUX FALSE)
SET(XCMAKE_OS_MAC FALSE)
IF("!${CMAKE_SYSTEM_NAME}" STREQUAL "!Windows")
    SET(XCMAKE_OS_WIN TRUE)
ELSEIF("!${CMAKE_SYSTEM_NAME}" STREQUAL "!Linux")
    SET(XCMAKE_OS_LINUX TRUE)
ELSEIF("!${CMAKE_SYSTEM_NAME}" STREQUAL "!Darwin")
    SET(XCMAKE_OS_MAC TRUE)
ELSE()
    MESSAGE(WARNING "unknown target os !")
ENDIF()
MESSAGE(STATUS "xcmake target os info:")
MESSAGE(STATUS "XCMAKE_OS=" ${XCMAKE_OS})
MESSAGE(STATUS "XCMAKE_OS_WIN=" ${XCMAKE_OS_WIN})
MESSAGE(STATUS "XCMAKE_OS_LINUX=" ${XCMAKE_OS_LINUX})
MESSAGE(STATUS "XCMAKE_OS_MAC=" ${XCMAKE_OS_MAC})

#设置XCMAKE 编译器环境变量
SET(XCMAKE_C_COMPILER ${CMAKE_C_COMPILER_ID})
SET(XCMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_ID})
SET(XCMAKE_COMPILER ${CMAKE_CXX_COMPILER_ID})
SET(XCMAKE_CLANG FALSE)
SET(XCMAKE_GUN FALSE)
SET(XCMAKE_MSVC FALSE)
IF("!${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
    MESSAGE(WARNING "c and cc use different compiler !")
ELSE()
    IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
        SET(XCMAKE_CLANG TRUE)
    ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
        SET(XCMAKE_GUN TRUE)
    ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
        SET(XCMAKE_MSVC TRUE)
    ELSE()
        MESSAGE(WARNING "unknown compiler !")
    ENDIF()
ENDIF()
MESSAGE(STATUS "xcmake cmopiler os info:")
MESSAGE(STATUS "XCMAKE_MSVC=" ${XCMAKE_MSVC})
MESSAGE(STATUS "XCMAKE_GUN=" ${XCMAKE_GUN})
MESSAGE(STATUS "XCMAKE_CLANG=" ${XCMAKE_CLANG})

IF(${XCMAKE_OS_WIN})
    MESSAGE(AUTHOR_WARNING "win-msvc: /utf-8")
    SET(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   /utf-8")
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
ENDIF()

# 设置输出路径
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINISIZEREL ${CMAKE_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINISIZERE ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINISIZERE ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/lib)


# 设置编译后缀
#set_target_properties(${TARGET_NAME} PROPERTIES DEBUG_POSTFIX "_d")
set(CMAKE_DEBUG_POSTFIX "_d")
#set(CMAKE_RELEASE_POSTFIX "_r")
set(CMAKE_MINISIZERE_POSTFIX "_m")
set(CMAKE_RELWITHDEBINFO_POSTFIX "_rd")

MESSAGE(STATUS "initiliaze XCMAKE environment finish !")
